﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CMS.Repository.Translator
{
    /// <summary>
    /// CourseTranslator
    /// Author:Fiona Pan
    /// </summary>
    public class CourseTranslator
    {
        /// <summary>
        /// Transfers CourseEF to CourseModel.
        /// </summary>
        /// <param name="inputCourse">CourseEF inputCourse</param>
        /// <returns>CourseModel outputCourse</returns>
        public static CMS.Model.Course ToCourseModel(Course inputCourse)
        {
            CMS.Model.Course outputCourse = new Model.Course();
            outputCourse.CourseId = inputCourse.CourseId;
            outputCourse.CourseName = inputCourse.CourseName;
            outputCourse.CourseStatus = inputCourse.CourseStatus;
            outputCourse.LevelId = inputCourse.LevelId;
            outputCourse.TeacherId = inputCourse.TeacherId;
            return outputCourse;
        }
        /// <summary>
        /// Transfers CourseModel to CourseEF
        /// </summary>
        /// <param name="inputCourse">CourseModel inputCourse</param>
        /// <returns>CourseEF outputCourse</returns>
        public static Course ToCourseEF(CMS.Model.Course inputCourse)
        {
            Course outputCourse = new Course();
            outputCourse.CourseId = inputCourse.CourseId;
            outputCourse.CourseName = inputCourse.CourseName;
            outputCourse.CourseStatus = inputCourse.CourseStatus;
            outputCourse.LevelId = inputCourse.LevelId;
            outputCourse.TeacherId = inputCourse.TeacherId;
            return outputCourse;
        }
        /// <summary>
        /// Transfers CourseEFList to CourseModelList.
        /// </summary>
        /// <param name="inputCourseList">CourseEF List inputCourseList</param>
        /// <returns>List of CourseModel</returns>
        public static List<CMS.Model.Course> ToCourseModelList(List<Course> inputCourseList)
        {
            List<CMS.Model.Course> outputCourseList = new List<Model.Course>();
            foreach (Course courseEF in inputCourseList)
            {
                CMS.Model.Level level = new Model.Level();
                CMS.Model.Teacher teacher = new Model.Teacher();
                level.LevelId = courseEF.LevelId;
                teacher.TeacherId = courseEF.TeacherId;
                CMS.Model.Course courseModel = new Model.Course(teacher,level);

                courseModel.CourseId = courseEF.CourseId;
                courseModel.CourseName = courseEF.CourseName;
                courseModel.Level.LevelName = courseEF.Level.LevelName;
                courseModel.Teacher.TeacherName = courseEF.Teacher.TeacherName;
                courseModel.CourseStatus = courseEF.CourseStatus;

                outputCourseList.Add(courseModel);
            }
            return outputCourseList;
        }
        /// <summary>
        /// Transfers to CourseEFList.
        /// </summary>
        /// <param name="inputCourseList">List of CourseModel inputCourseList</param>
        /// <returns>List of CourseEF outputCourseList</returns>
        public static List<Course> ToCourseEFList(List<CMS.Model.Course> inputCourseList)
        {
            List<Course> outputCourseList = new List<Course>();
            foreach(CMS.Model.Course courseModel in inputCourseList)
            {
                Course courseEF = new Course();
                courseEF.CourseId = courseModel.CourseId;
                courseEF.CourseName = courseModel.CourseName;
                courseEF.CourseStatus = courseModel.CourseStatus;
                courseEF.LevelId = courseModel.Level.LevelId;
                courseEF.TeacherId = courseModel.Teacher.TeacherId;
                outputCourseList.Add(courseEF);
            }
            return outputCourseList;
        }
    }
}
